//
//  CommissionExCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/3/16.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "CommissionExCell.h"

@implementation CommissionExCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupView];
    }
    return self;
}

- (void)setupView
{
    CGFloat margin = 15;
    
    NSInteger fontSize;
    if (iPhone5) {
        fontSize = 12;
    }else{
        fontSize = 13;
    }
//    [UIFont fontWithName:@"STHeitiSC-Light" size:f]
    self.userNameLabel = [[UILabel alloc] init];
    _userNameLabel.font = FONT(fontSize);
    [self addSubview:_userNameLabel];
    _userNameLabel.text = @"大大大大大";
    _userNameLabel.textColor = [UIColor blackColor];
    
    self.extensionLevelImg = [[UIImageView alloc] init];
    [self addSubview:_extensionLevelImg];
    _extensionLevelImg.image = [UIImage imageNamed:@"tubiao108"];
    _extensionLevelImg.contentMode = UIViewContentModeScaleAspectFit;
    
    self.extensionMoney = [[UILabel alloc] init];
    _extensionMoney.textAlignment = NSTextAlignmentRight;
    _extensionMoney.textColor = DEFAULT_COLOR;
    _extensionMoney.font = FONT(fontSize);
    [self addSubview:_extensionMoney];
    _extensionMoney.text = @"9.00";
    
    //分割线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor blackColor];
    lineView.alpha = 0.1;
    [self.contentView addSubview:lineView];
    
    self.goodsImg = [[UIImageView alloc] init];
    [self addSubview:_goodsImg];
    _goodsImg.image = [UIImage imageNamed:@"tubiao108"];

    self.goodsNameLabel = [[UILabel alloc] init];
    _goodsNameLabel.font = FONT(fontSize);
    _goodsNameLabel.numberOfLines = 2;
    [self addSubview:_goodsNameLabel];
    _goodsNameLabel.text = @"大打算打打死大大神算打打死大大神算打打死大大神算打打死大大神大神大神大神大神大神大神大多数";
//

    _timeLabel = [[UILabel alloc] init];
    _timeLabel.font = FONT(fontSize-1);
    _timeLabel.textColor = [UIColor grayColor];
    [self addSubview:_timeLabel];
    _timeLabel.text = @"1212121212";

    
    _goodsPriceLabel = [[UILabel alloc] init];
    _goodsPriceLabel.font = FONT(fontSize);
    [self addSubview:_goodsPriceLabel];
    _goodsPriceLabel.text = @"1212";
    
    _goodsNumLabel = [[UILabel alloc] init];
    _goodsNumLabel.font = FONT(fontSize);
    [self addSubview:_goodsNumLabel];
    _goodsNumLabel.text = @"12";

//
    __weak typeof(self) weakSelf = self;
    [_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_top).offset(10);
        make.left.equalTo(weakSelf.mas_left).offset(margin);
    }];
//
    [_extensionLevelImg mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerY.equalTo(_userNameLabel.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-margin);
        make.width.height.mas_equalTo(15);
    }];

    
    [_extensionMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_userNameLabel.mas_centerY);
        make.right.equalTo(_extensionLevelImg.mas_left).offset(-10);
    }];
    
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(_userNameLabel.mas_bottom).offset(10);
        make.width.mas_equalTo(WIDTH-margin*2);
        make.leading.equalTo(_userNameLabel.mas_leading);
        make.height.mas_equalTo(0.5);
    }];
    
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lineView.mas_bottom).offset(10);
        make.leading.equalTo(_userNameLabel.mas_leading);
        make.width.height.mas_equalTo(60);
    }];
    
    [_goodsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(WIDTH - 110);
        make.top.equalTo(_goodsImg.mas_top);
        make.left.equalTo(_goodsImg.mas_right).offset(5);
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_goodsImg.mas_bottom);
        make.left.equalTo(_goodsImg.mas_right).offset(5);
    }];
    
    [_goodsPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_goodsImg.mas_bottom);
        make.right.equalTo(lineView.mas_right);
    }];
    
    [_goodsNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(lineView.mas_right);
        make.bottom.equalTo(_goodsPriceLabel.mas_top).offset(-5);
    }];
    
    
}



@end
